<!-- 查看图片 -->
<template>
	<div class="view">
		<div class="adds">
			{{ getAddress(rowData) }}
		</div>

		<div class="ImgBox">
			<video-webrtc ref="rtcVideo" :deviceCode="props.rowData.deviceCode" style="width: 100%" />
		</div>

		<div class="btns">
			<div class="btn" @click="close(props.rowData.deviceCode)">
				<CircleClose />
			</div>

			<div class="btn" @click="getVideo">
				<Refresh />
			</div>
		</div>
	</div>
</template>

<script lang="ts" setup name="ViewVideo">
import { reactive, onMounted, ref, watch, onBeforeUnmount, nextTick, computed, defineProps } from 'vue';
import { Refresh, CircleClose } from '@element-plus/icons-vue';
import { useSmoke } from '/@/hook/index';
import { smokeStore } from '/@/stores/smoke';
// import myVideo from '/@/components/smoke/myVideo/video-webrtc.vue';
// import videoMpegts from "../../components/myVideo/Video-mpegts-flv.vue";
// import videoWebrtc from '/@/components/smoke/myVideo/video-webrtc.vue';
import videoWebrtc from '/@/components/smoke/myVideo/webrtc/video-webrtc.vue';
const { getFileUrl, getAddress } = useSmoke();

const rtcVideo = ref();

// props
const props = defineProps({
	rowData: <any>{
		type: Object,
	},
});

const emit = defineEmits(['closeVideo']);

onMounted(() => {});

function getVideo() {
	rtcVideo.value.wsGetVideo();
	rtcVideo.value.startVideo();
}

function close(deviceCode: string) {
	emit('closeVideo', deviceCode);
}
</script>
<style lang="scss" scoped>
.view {
	width: 100%;
	height: 100%;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden;
	background-color: #dedfe0;

	.adds {
		position: absolute;
		right: 0;
		top: 0;
		background: rgba($color: #000000, $alpha: 0.6);
		padding: 5px 10px;
		font-size: 14px;
		z-index: 100;
		color: rgba(255, 255, 255, 0.8);
	}

	.ImgBox {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;

		video {
			max-width: 100%;
			aspect-ratio: 16/9;
		}

		color: #f56c6c;
	}

	.btns {
		position: absolute;
		right: 0;
		z-index: 10;
		display: grid;
		gap: 20px;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		.btn {
			width: 40px;
			height: 40px;
			padding: 10px;
			background-color: rgba($color: #000000, $alpha: 0.5);
			color: #fff;

			&:nth-child(1) {
				color: #f56c6c;
			}

			&:nth-child(2) {
				color: #67c23a;
			}

			&:hover {
				background-color: rgba($color: #000000, $alpha: 0.8);
			}
		}
	}
}
</style>
